package com;

import java.util.Scanner;

//数组的扩容
public class FourTest {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个数字");
        int one = input.nextInt();
        int[] nums = {32,35,68,34,65};
        System.out.println(nums.length);
        int[] newNums = new int[nums.length+1];//原数组长度+1

        //复制原数组元素进入新数组
        for(int i= 0; i<nums.length; i++){
            newNums[i] = nums[i];//将原数组元素赋值给新数组
        }
        nums = newNums;//将新数组的引用赋值给原数组的引用

        nums[nums.length-1] = one;//将新元素插入到数组最后一位

        for(int num :nums){
            System.out.println(num);
        }
    }
}
